   <html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <title>微信安全支付</title>
    <script type="text/javascript">
        // $(function () {
        //
        // })


        //调用微信JS api 支付
        function onBridgeReady(){
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId":"<?= $res['appid'];?>",     //公众号名称，由商户传入
                    "timeStamp":"1395712654",         //时间戳，自1970年以来的秒数
                    "nonceStr":"<?= $res['nonce_str'];?>", //随机串
                    "package":"prepay_id=<?= $res['prepay_id'];?>",
                    "signType":"MD5",         //微信签名方式：
                    "paySign":"<?= $res['sign'];?>" //微信签名
                },
                // ["appid"] => string(18) "wx69e9cc2f67138256"
                // ["mch_id"] => string(10) "1313423601"
                // ["nonce_str"] => string(16) "T61NXsmv20I923Xq"
                // ["sign"] => string(32) "D79F585AE774D3751E862B9998366C12"
                // ["result_code"] => string(7) "SUCCESS"
                // ["prepay_id"] => string(36) "wx2713592337489366d14f98743525989243"
                // ["trade_type"] => string(5) "JSAPI"
                function(res){
                    if(res.err_msg == "get_brand_wcpay_request:ok" ){
                        // 使用以上方式判断前端返回,微信团队郑重提示：
                        //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                    }
                });
        }
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }
    </script>
</head>
<body>
    </br></br></br></br>
    <div align="center">
        <button style="width:210px; height:30px; background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="onBridgeReady()" >点击购买</button>
    </div>
</body>
</html>